﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SFP;
using SFP.CollisionDetection;
using HamsterDelivery.LevelStructure;
using HamsterDelivery.LevelStructure.GameObjects;

namespace HamsterDelivery.LevelStructure.Reactions
{
    public class JumpingLetterReaction : GlobalReaction
    {
        private LetterObject letter;

        public JumpingLetterReaction(LetterObject letter)
        {
            this.letter = letter;
        }

        protected override void fromBeneath(HashSet<CollisionInfo> collisionInfos)
        {
            CollisionInfo collisionInfo = ReactionUtils.collisionMaxOverlap(collisionInfos);

            letter.VelocityY = 0;
            letter.VelocityX = 0;
            letter.Y += collisionInfo.Overlap;
        }

        protected override void fromAbove(HashSet<CollisionInfo> collisionInfos)
        {
            CollisionInfo collisionInfo = ReactionUtils.collisionMaxOverlap(collisionInfos);

            letter.Jumping = false;
            letter.VelocityY = 0;
            letter.VelocityX = 0;
            letter.Y -= collisionInfo.Overlap;
        }

        protected override void fromLeft(HashSet<CollisionInfo> collisionInfos)
        {
            CollisionInfo collisionInfo = ReactionUtils.collisionMaxOverlap(collisionInfos);

            letter.VelocityX = 0;
            letter.X -= collisionInfo.Overlap;
        }

        protected override void fromRight(HashSet<CollisionInfo> collisionInfos)
        {
            CollisionInfo collisionInfo = ReactionUtils.collisionMaxOverlap(collisionInfos);

            letter.VelocityX = 0;
            letter.X += collisionInfo.Overlap;
        }

        protected override void touchesTop(HashSet<CollisionInfo> collisionInfos)
        {
        }

        protected override void touchesBottom(HashSet<CollisionInfo> collisionInfos)
        {
        }

        protected override void touchesLeft(HashSet<CollisionInfo> collisionInfos)
        {
        }

        protected override void touchesRight(HashSet<CollisionInfo> collisionInfos)
        {
        }
    }
}
